import react from "@vitejs/plugin-react";
import path from "path";
import { defineConfig } from "vite";
import svgr from "vite-plugin-svgr";

const target = {
  dev: "XXX",
  it: "XXX",
  prod: "XXX",
};

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), svgr()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  build: {
    rollupOptions: {
      output: {
        assetFileNames: `assets/[name].[ext]`, // 资源文件不加hash，为了让小程序直接加载部分需要的图片
      },
    },
  },
  server: {
    host: true,
    proxy: {
      "/api": {
        target: target.it,
        changeOrigin: true,
      },
    },
  },
});
